package chapter04;

/**
 * 1.继承
 * 2.重写
 */
class Flower{//花朵类
    String color;//花瓣颜色
    int petalNumber;//花瓣数量
    String petalType;//花瓣类型
    String florescence;//花期
    public void seFlorescence(String florescence){
        this.florescence = florescence;
    }
    public String getFlorescence(){
        return florescence;
    }
    public void setColor(String color){
        this.color = color;//设置花瓣颜色
    }
    public String getColor(){
        return color;
    }
}
// 牡丹类继承了花朵类
class Peony extends  Flower{
    public void flowerlanguage(){
        String florescence;
        System.out.println("圆满、浓情、富贵、吉祥、幸福、雍容华贵、国色天香");
    }
    public void setflorescence(String florescence){
        if (this.color.equals("黄色")){ // 黄色花朵都是五月
            this.florescence = "五月";
        }else {
            this.florescence = florescence;//用户输入的花期
        }
    }
}
public class Demo1 {
    public  static  void main(String[] args){
        Peony peony = new Peony();
        peony.setColor("黄色");
        peony.setflorescence("3月-4月");
        System.out.println("黄色牡丹花期"+ peony.getFlorescence());
        peony.petalNumber = 1000;
        peony.petalType = "重瓣型";
        System.out.println("牡丹花颜色" + peony.getColor());
        peony.flowerlanguage();
    }
}
